<!doctype html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title>商品管理</title>
    <link rel="stylesheet" type="text/css" href="css/common.css"/>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <script src="assets/js/jquery.min.js"></script>
</head>
<body>
<div class="topbar-wrap white">
    <div class="topbar-inner clearfix">
        <div class="topbar-logo-wrap clearfix">
            <h1 class="topbar-logo none"><a href="index.html" class="navbar-brand">后台管理</a></h1>
            <ul class="navbar-list clearfix">
                <li><a class="on" href="index.html">首页</a></li>
                <li><a href="#" target="_blank">网站首页</a></li>
            </ul>
        </div>
        <div class="top-info-wrap">
            <ul class="top-info-list clearfix">
                <li><a href="#">管理员</a></li>
                <li><a href="#">修改密码</a></li>
                <li><a href="#">退出</a></li>
            </ul>
        </div>
    </div>
</div>
<div class="container clearfix">
    <div class="sidebar-wrap">
        <div class="sidebar-title">
            <h1>菜单</h1>
        </div>
        <div class="sidebar-content">
            <ul class="sidebar-list">
                <li>
                    <a href="#"><i class="icon-font">&#xe003;</i>常用操作</a>
                    <ul class="sub-menu">
                        <li><a href="index.html"><i class="icon-font">&#xe008;</i>用户管理</a></li>
                        <li><a href="products.html"><i class="icon-font">&#xe005;</i>作品管理</a></li>
                        <li><a href="sowing.html"><i class="icon-font">&#xe006;</i>轮播图管理</a></li>
                        <li><a href="index.html"><i class="icon-font">&#xe004;</i>留言管理</a></li>
                        <li><a href="index.html"><i class="icon-font">&#xe012;</i>评论管理</a></li>
                        <li><a href="index.html"><i class="icon-font">&#xe052;</i>友情链接</a></li>
                        <li><a href="index.html"><i class="icon-font">&#xe033;</i>广告管理</a></li>
                    </ul>
                </li>
                <li>
                    <a href="#"><i class="icon-font">&#xe018;</i>系统管理</a>
                    <ul class="sub-menu">
                        <li><a href="system.html"><i class="icon-font">&#xe017;</i>系统设置</a></li>
                        <li><a href="system.html"><i class="icon-font">&#xe037;</i>清理缓存</a></li>
                        <li><a href="system.html"><i class="icon-font">&#xe046;</i>数据备份</a></li>
                        <li><a href="system.html"><i class="icon-font">&#xe045;</i>数据还原</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="index.html">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">作品管理</span></div>
        </div>
        <div class="search-wrap">
            <div class="search-content">
                <form action="#" method="post">
                    <table class="search-tab">
                        <tr>
                            <th width="120">选择分类:</th>
                            <td>
                                <select name="search-sort" id="search-sort">
                                    <option value="18">全部</option>
                                    <option value="19">已上架</option><option value="20">已下架</option>
                                </select>
                            </td>
                            <td><input class="btn btn-primary btn2" id="sum" value="查询" ></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
        <div class="result-wrap">
            <form name="myform" id="myform" method="post">
                <div class="result-title">
                    <div class="result-list">
                    		<a href="insert.html"><i class="icon-font"></i>新增作品</a>
                    </div>
                </div>
                <div class="result-content">
                    <table class="result-tab" width="100%">
                        <tr>
                            <th class="tc" width="5%"><input class="allChoose" name="" type="checkbox"></th>
                            <th>作品编号</th>
                            <th>作品名称</th>
                            <th>缩略图</th>
                            <th>用户编号</th>
                            <th>用户姓名</th>
                            <th>作品分类</th>
                            <th>价格</th>
                            <th>新增时间</th>
                            <th>操作</th>
                        </tr>
                      <!--   <tr>
                            <td class="tc"><input name="id[]" value="58" type="checkbox"></td>
                            <td class="bh"> </td>
                            <td class="name">58</td>
                            <td class="image"><img alt="" src="" width="60px"></td>
                            <td class="user_id"></td>
                            <td class="user_name"></td>
                            <td class="type"></td>
                            <td class="price"></td>
                            <td class="starttime"></td>
                            <td>
                                <a class="link-update" href="#">修改</a>
                                <a class="link-del" href="#">删除</a>
                            </td>
                        </tr> -->
                    </table>
                    <div class="list-page"> 10 条 1/1 页</div>
                </div>
            </form>
        </div>
    </div>
    <!--/main-->
</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
	$("#sum").click(function(){
		$(".result-tab").html("");
		$(".result-tab").append( '<tr>'+
        '<th class="tc" width="5%"><input class="allChoose" name="" type="checkbox"></th>'+
        '<th>作品编号</th>'+
        '<th>作品名称</th>'+
        '<th>缩略图</th>'+
        '<th>用户编号</th>'+
        '<th>用户姓名</th>'+
        '<th>作品分类</th>'+
        '<th>价格</th>'+
        '<th>新增时间</th>'+
        '<th>操作</th>'+
    '</tr>');
		var sel = $("#search-sort").val();
		$.post("selectproducts_1", {"sel":sel,"pagemodel.currentPage":1}, function(data){
			$(".list-page").html( "10 条"+ data.total.currentPage+"/"+data.total.totalPage +"页");
			for ( var i in data.result) {
				var type="";
				if (data.result[i].styletype==0) {
					type="景色"
				} else if (data.result[i].styletype==1){
					type="人物"
				}else{
					type="科技"
					}
				if (data.result[i].state==0) {
					$(".result-tab").append( '<tr>'+
			                '<td class="tc"><input name="id[]" value="58" type="checkbox"></td>'+
			                '<td class="bh">'+data.result[i].id+'</td>'+
			                '<td class="name">'+data.result[i].name+'</td>'+
			                '<td class="image"><img alt="" src="'+data.result[i].prhotourl+'" width="100px"></td>'+
			                '<td class="user_id">'+data.result[i].user.id+'</td>'+
			                '<td class="user_name">'+data.result[i].user.username+'</td>'+
			                '<td class="type">'+type+'</td>'+
			                '<td class="price">'+data.result[i].price+'</td>'+
			                '<td class="starttime">'+data.result[i].phototime+'</td>'+
			                '<td>'+
			                    '<a class="linkdelete" href="#" name="'+data.result[i].id+'">下架&emsp;</a>'+
			                    '<a class="link-look" href="#" name="'+data.result[i].id+'">查看&emsp;</a>'+
			                    '<a class="link-update" href="updateproducts.html?work_id='+data.result[i].id+'">修改</a>'+
			                '</td>'+
			            '</tr>')
				} else {
					$(".result-tab").append( '<tr>'+
			                '<td class="tc"><input name="id[]" value="58" type="checkbox"></td>'+
			                '<td class="bh">'+data.result[i].id+'</td>'+
			                '<td class="name">'+data.result[i].name+'</td>'+
			                '<td class="image"><img alt="" src="'+data.result[i].prhotourl+'" width="100px"></td>'+
			                '<td class="user_id">'+data.result[i].user.id+'</td>'+
			                '<td class="user_name">'+data.result[i].user.username+'</td>'+
			                '<td class="type">'+type+'</td>'+
			                '<td class="price">'+data.result[i].price+'</td>'+
			                '<td class="starttime">'+data.result[i].phototime+'</td>'+
			                '<td>'+
			                    '<a class="link-look" href="#" name="'+data.result[i].id+'">查看&emsp;</a>'+
			                    '<a class="link-update" href="updateproducts.html?work_id='+data.result[i].id+'">修改</a>'+
			                '</td>'+
			            '</tr>')
				}
				
			}
		})
	})
		$.post("selectproducts",{"pagemodel.currentPage":1},function(data){
			$(".list-page").html( "10 条"+ data.total.currentPage+"/"+data.total.totalPage +"页");
			for ( var i in data.result) {
				var type="";
				if (data.result[i].styletype==0) {
					type="景色"
				} else if (data.result[i].styletype==1){
					type="人物"
				}else{
					type="科技"
					}
				$(".result-tab").append( '<tr>'+
                '<td class="tc"><input name="id[]" value="58" type="checkbox"></td>'+
                '<td class="bh">'+data.result[i].id+'</td>'+
                '<td class="name">'+data.result[i].name+'</td>'+
                '<td class="image"><img alt="" src="'+data.result[i].prhotourl+'" width="100px"></td>'+
                '<td class="user_id">'+data.result[i].user.id+'</td>'+
                '<td class="user_name">'+data.result[i].user.username+'</td>'+
                '<td class="type">'+type+'</td>'+
                '<td class="price">'+data.result[i].price+'</td>'+
                '<td class="starttime">'+data.result[i].phototime+'</td>'+
                '<td>'+
                    '<a class="linkdelete" href="#" name="'+data.result[i].id+'">下架&emsp;</a>'+
                    '<a class="link-look" href="#" name="'+data.result[i].id+'">查看&emsp;</a>'+
                    '<a class="link-update" href="updateproducts.html?work_id='+data.result[i].id+'">修改</a>'+
                '</td>'+
            '</tr>')
			}
//==============================下架作品======================
			$(".linkdelete").click(function(){
				 var user_id=$(this).attr("name");
				$.post("worksstate",{"works.id":user_id} ,function(data){
					if (data.isSuccess) {
						alert("下架成功");
						window.location.reload();
					} else {
						alert("下架失败");
					}
				})
			})
	})
})
</script>
</html>